package com.zgroup.domain

class Picture implements Comparable {

  public final static String ESTATE_TYPE = "10";
  public final static String LAYOUT_TYPE = "20";
  public final static String HOUSE_TYPE = "30";

  String fileName

  InfoRelease info

  Date dateCreated

  String type = ESTATE_TYPE
  String description
  Estate fromEstate


  static transients = ['fileFullName', 'thumbFullName']

  int compareTo(obj) {
    dateCreated.compareTo(obj.dateCreated)
  }

  static constraints = {
    fileName(blank: false, maxSize: 50)
    type(blank: false, maxSize: 6)
    info(nullable: true)
    description(nullable: true,, maxSize: 255)
    fromEstate(nullable: true,)
  }

  static mapping = {
    dynamicInsert true
    dynamicUpdate true
  }

  String getFileFullName() {
    return InfoRelease.UPLOAD_FILE_PATH + fileName
  }

  String getThumbFullName() {
    return InfoRelease.UPLOAD_THUMBNAIL_PATH + fileName
  }

  String toString() {
    "id:" + id
  }
}
